/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ec.edu.espe.distribuidas.courier.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author cHr15t14n
 */
@Entity
@Table(name = "guia_madre")
public class GuiaMadre implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_GUIA", nullable = false)
    private Integer idGuia;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_VUELO", nullable = false)
    private int idVuelo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "NUMERO_GUIA_AEREA", nullable = false, length = 20)
    private String numeroGuiaAerea;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PESO_TOTAL_DECLARADO", nullable = false, precision = 8, scale = 4)
    private BigDecimal pesoTotalDeclarado;
    @Column(name = "PESO_TOTAL_REAL", precision = 8, scale = 4)
    private BigDecimal pesoTotalReal;
    @Column(name = "CANTIDAD_PAQUETES")
    private Integer cantidadPaquetes;

    @OneToMany(mappedBy = "guiaMadre")
    private List<Paquete> paqueteList;

    @JoinColumn(name = "ID_VUELO", referencedColumnName = "ID_VUELO")
    @ManyToOne
    private Vuelo vuelo;

    public GuiaMadre() {
    }

    public GuiaMadre(Integer idGuia) {
        this.idGuia = idGuia;
    }

    public GuiaMadre(Integer idGuia, int idVuelo, String numeroGuiaAerea, BigDecimal pesoTotalDeclarado) {
        this.idGuia = idGuia;
        this.idVuelo = idVuelo;
        this.numeroGuiaAerea = numeroGuiaAerea;
        this.pesoTotalDeclarado = pesoTotalDeclarado;
    }

    public Integer getIdGuia() {
        return idGuia;
    }

    public void setIdGuia(Integer idGuia) {
        this.idGuia = idGuia;
    }

    public List<Paquete> getPaqueteList() {
        return paqueteList;
    }

    public void setPaqueteList(List<Paquete> paqueteList) {
        this.paqueteList = paqueteList;
    }

    public Vuelo getVuelo() {
        return vuelo;
    }

    public void setVuelo(Vuelo vuelo) {
        this.vuelo = vuelo;
    }

    public int getIdVuelo() {
        return idVuelo;
    }

    public void setIdVuelo(int idVuelo) {
        this.idVuelo = idVuelo;
    }

    public String getNumeroGuiaAerea() {
        return numeroGuiaAerea;
    }

    public void setNumeroGuiaAerea(String numeroGuiaAerea) {
        this.numeroGuiaAerea = numeroGuiaAerea;
    }

    public BigDecimal getPesoTotalDeclarado() {
        return pesoTotalDeclarado;
    }

    public void setPesoTotalDeclarado(BigDecimal pesoTotalDeclarado) {
        this.pesoTotalDeclarado = pesoTotalDeclarado;
    }

    public BigDecimal getPesoTotalReal() {
        return pesoTotalReal;
    }

    public void setPesoTotalReal(BigDecimal pesoTotalReal) {
        this.pesoTotalReal = pesoTotalReal;
    }

    public Integer getCantidadPaquetes() {
        return cantidadPaquetes;
    }

    public void setCantidadPaquetes(Integer cantidadPaquetes) {
        this.cantidadPaquetes = cantidadPaquetes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idGuia != null ? idGuia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GuiaMadre)) {
            return false;
        }
        GuiaMadre other = (GuiaMadre) object;
        if ((this.idGuia == null && other.idGuia != null) || (this.idGuia != null && !this.idGuia.equals(other.idGuia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ec.edu.espe.distribuidas.courier.modelo.GuiaMadre[ idGuia=" + idGuia + " ]";
    }

}
